import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import processing.core.PApplet;


public class ComparisonTest extends PApplet {

	List <Corner> corners = new ArrayList();

	static final boolean isEvenStatic(int n) {
		return (n & 1) == 0;
	}
	
	boolean isEven(int n){
		return n % 2 == 0;
	}
	
	public void test(){
		boolean b;
		//b = isEvenStatic(22);
		b = isEven(22);
		
	}
	public void setup() {
		for (int i=0; i<5; i++) {
			float ele = random(10);
			Corner c = new Corner(ele, i);
			corners.add(c);
		}

		for (Corner c : corners) {
			System.out.println(c.elevation + "  " + c.index);
		}
		println("----");

		Collections.sort(corners);

		for (Corner c : corners) {
			println(c.elevation, c.index);
		}
	}

	public void draw() {
	}

	class Corner implements Comparable<Corner> {
		float elevation;
		int index;

		Corner () {
		}

		Corner (float elevation, int index) {
			this.elevation = elevation;
			this.index = index;
		}

		// This method is required due to implementing comparable
		public int compareTo(Corner c0) {
			return (int) Math.signum(elevation - c0.elevation);
		}
	}

	class SortByElevation implements Comparator<Corner>  {

		public int compare(Corner c0, Corner c1) {
			return  (int) Math.signum(c0.elevation - c1.elevation);
		}

	}
}
